package com.jswty.zabbix;

import com.jswty.JsonUtil;
import io.netty.buffer.ByteBuf;

import java.util.HashMap;
import java.util.Map;

/**
 * @author senowang
 * @date 2018/10/15 - 15:41
 */
public class ActiveMessage {
    private static final String REQUEST = "request";
    private static final String SENDER_DATA = "sender data";
    private static final String DATA = "data";
    private Map map;
    private String message;
    
    public ActiveMessage(Object message) {
        map = new HashMap<>(2);
        map.put(REQUEST, SENDER_DATA);
        String s = JsonUtil.toJsonString(message);
        map.put(DATA, s);
        this.message = JsonUtil.toJsonString(map);
    }
    
    public ByteBuf getMessageByteBuf() {
        return ProtocolMsgHandler.getMessageByteBuf(message);
    }
}
